export function useReg() {
  const dateReg = /\d{4}([-/.])\d{2}\1\d{2}/
  const str = dateReg.exec('日期至2021-09-09结束')
  console.log(str)

  function hump2KebabCase(name: string) {
    return name.replace(/\B([A-Z])/g, '-$1').toLowerCase()
  }
  const name = 'CaoYoung'
  console.log(hump2KebabCase(name))

  function kebabCase2Hump(name: string) {
    return name.replace(/-([a-z])/g, (substring, args) => {
      return args.toUpperCase()
    })
  }

  const num = 1234567890
  // num.toLocaleString()
  function thousandSeparator(num: string | number) {
    if (typeof num === 'number') num = num.toString()
    return num.replace(/(?=(\B\d{3})+$)/g, ',')
  }
  console.log(thousandSeparator(num))

  const reg3 = /\d+(\.\d+)?(?=元)/g
  const str3 = '我的口袋里还有10元，你的口袋里还有12.4元'
  console.log(str3.match(reg3))

  return {
    dateReg,
    hump2KebabCase,
    kebabCase2Hump,
    thousandSeparator
  }
}
